package org.hongqi.common.senpec.person.certification;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Transient;
import lombok.*;
import org.hongqi.common.senpec.base.mybatisplus.IBaseEntity;
import org.hongqi.common.senpec.file.fileInfo.FileInfo;
import org.hongqi.common.senpec.sys.user.User;

import java.time.LocalDate;

@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity(name = "senpec_person_certification")
@TableName("senpec_person_certification")
public class Certification extends IBaseEntity<Certification> {
    private String certificationNo;//证书编号

    private String userUsername;//证书持有者用户名

    @Transient
    @TableField(exist = false)
    private User userObj;

    private String zone;  //证书所属领域

    private String method;//方法简称如UT/RT/ET等
    @Transient
    @TableField(exist = false)
    private String methodStr;

    private String level; //证书等级

    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd")

    private LocalDate certifyDate;
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd")

    private LocalDate startDate;
    @JsonDeserialize(using = LocalDateDeserializer.class)
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd")

    private LocalDate endDate;

    @Transient
    @TableField(exist = false)
    @Builder.Default
    private Boolean isValid = true;

    @Column(length = 100)
    private String attachmentUuid;

    @Transient
    @TableField(exist = false)
    private FileInfo attachmentObj;

}
